package com.lancoo.znbkxx.teacher.aibkTestCoach.studyAnalysis

import android.app.Activity
import android.content.Intent
import android.view.View
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.entity.Stu
import kotlinx.android.synthetic.main.item_study_analysis_rank.view.*
import java.math.BigDecimal

/**
 * Created by Dadong on 2021/2/23
 * Describe:
 */
class ListRankAdapter(activity: Activity, layoutResId: Int, stuList: MutableList<Stu>)
    : BaseQuickAdapter<Stu, BaseViewHolder>(layoutResId, stuList) {
    private var mActivity: Activity = activity
    override fun convert(helper: BaseViewHolder, item: Stu?) {
        with(helper.itemView) {
            when (helper.position) {
                0 -> {
                    iv_rank.setImageResource(R.mipmap.icon_rank_one)
                    tv_rank.visibility = View.GONE
                }
                1 -> {
                    iv_rank.setImageResource(R.mipmap.icon_rank_two)
                    tv_rank.visibility = View.GONE
                }
                2 -> {
                    iv_rank.setImageResource(R.mipmap.icon_rank_three)
                    tv_rank.visibility = View.GONE
                }
                else -> {
                    iv_rank.visibility = View.GONE
                    tv_rank.text = item!!.StuRank.toString()
                }
            }
            tv_name.text = item!!.StuName
            tv_num.text = item.StuCompleteNum.toString()
            tv_scoring.text = (item.StuPaperRate * 100).toBigDecimal().setScale(0, BigDecimal.ROUND_HALF_UP).toString()
            this.setOnClickListener {
                val intent = Intent(mActivity, StuStudyAnalysisActivity::class.java).apply {
                    putExtra("stuId", item.StuID)
                }
                mActivity.startActivity(intent)
            }
        }
    }

}